﻿
@{
    ViewData["Title"] = "排管管理";
    Layout = "~/Views/Shared/_Layout_Content.cshtml";
}

@section styles
    {
    <environment names="Development">
        <link href="~/css/plugins/jqgrid/ui.jqgrid.css" rel="stylesheet" />
    </environment>
    <environment names="Staging,Production">
        <link rel="stylesheet" href="~/css/grid.min.css" asp-append-version="true" />
    </environment>
}

<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5><a href="../PaiBan/index">公司排班</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="../PaiBan/WorkIndex">人员排班</a></h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
            </div>
        </div>
        <div class="ibox-content">
            <div class="form-group">
                @*<button id="btnAdd" type="button" class="btn btn-primary " onclick="addModel()"><i class="fa fa-check"></i>&nbsp;添加</button>*@
                <button id="btnEdit" type="button" class="btn btn-info " onclick="editModel()"><i class="fa fa-paste"></i> 编辑</button>
                <button id="btnDel" type="button" class="btn btn-danger " onclick="delData()">
                    <i class="fa fa-dedent"></i>&nbsp;&nbsp;<span class="bold">删除</span>
                </button>

            </div>

            <div class="form-group">
                <div class="input-group">
                    <input id="txtSearchKey" type="text" class="input form-control" placeholder="班次名称" />
                    <span class="input-group-btn">
                        <button id="btnSearch" class="btn btn btn-primary" type="button"> <i class="fa fa-search"></i> 搜索</button>
                    </span>
                </div>
            </div>

            <div class="jqGrid_wrapper">
                <table id="table_list"></table>
                <div id="pager_list"></div>
            </div>
        </div>
    </div>
</div>

@section scripts
    {
    <environment names="Development">
        <script src="~/js/plugins/jqgrid/jquery.jqGrid.js"></script>
        <script src="~/js/plugins/jqgrid/i18n/grid.locale-cn.js"></script>
        <script src="~/js/jqgrid-list.js"></script>
        <script src="~/js/json2.js"></script>
        <script src="~/js/base.js"></script>
    </environment>
    <environment names="Staging,Production">
        <script src="~/js/grid.min.js" asp-append-version="true"></script>
    </environment>
    <script>
        function addModel() {
            $("#btnAdd").button("loading");
            window.location.href = "@Url.Action("Add")";
        }

        function editModel() { //编辑
            var row = JucheapGrid.GetData();
            if (row != null) {
                $("#btnEdit").button("loading");
                window.location.href = "@Url.Action("EditWorkerPaiBan")/" + row.id;
            } else {
                alert("请选择要编辑的数据");
            }
        }

        function delData() { //删除
            XPage.DelData("@Url.Action("Delete")");
        }

        function searchData() { //搜索
            var json = {
                name: $("#txtSearchKey").val()
            };
            XPage.Search(json);
        }

        $(document).ready(function() {
           var config = {
                title: '排班列表',
                url: '@Url.Action("GetListWorkerWithPager")',
               colNames: ['主键', '公司', '人员', '班次','时间段'],
                colModel: [
                    { name: 'id', index: 'id', width: 60, key: true, hidden: true },
                    { name: 'company', index: 'company', width: 60 },
                    { name: 'workerName', index: 'workerName', width: 60 },
                    { name: 'banciName', index: 'banciName', width: 60 },
                    { name: 'timePeriods', index: 'timePeriods', width: 60 },
                ]
            };
            JucheapGrid.Load(config);
            $("#btnSearch").bind("click", searchData);

        });
    </script>
}
